<?php
require '../resources/getConnection.php';
    
?>
<div id='menu'>
    <ul>
        <li><a href='index.php'><span>Home</span></a></li>
        <li><a href="devices.php"><span>Ger&auml;te</span></a>
            <ul>
                <?php
                    $MenuDevices=new Devices($connection);
                    $deviceTypeType=$MenuDevices->DeviceTypes;
                    $deviceTypeId=$MenuDevices->DeviceTypesID;
                    $lenght=count($deviceTypeType);
                    echo "<li><a href=\"devices.php\"><span>Alle</span></a></li>";
                    if(in_array('Pc', $deviceTypeType)){
                        $tempId = array_search('Pc', $deviceTypeType);
                        $deviceTypeType[$tempId]='Computer';
                        echo "<li><a href=\"devices.php?d=$deviceTypeId[$tempId]\"><span>".sanitizeOutputString($deviceTypeType[$tempId])."</span></a></li>";
                        unset($deviceTypeType[$tempId]);
                    }
                    if(in_array('Printer', $deviceTypeType)){
                        $tempId = array_search('Printer', $deviceTypeType);
                        $deviceTypeType[$tempId]='Drucker';
                        echo "<li><a href=\"devices.php?d=$deviceTypeId[$tempId]\"><span>".sanitizeOutputString($deviceTypeType[$tempId])."</span></a></li>";
                        unset($deviceTypeType[$tempId]);
                    }
                    if(in_array('Screen', $deviceTypeType)){
                        $tempId = array_search('Screen', $deviceTypeType);
                        $deviceTypeType[$tempId]='Bildschirm';
                        echo "<li><a href=\"devices.php?d=$deviceTypeId[$tempId]\"><span>".sanitizeOutputString($deviceTypeType[$tempId])."</span></a></li>";
                        unset($deviceTypeType[$tempId]);
                    }
                    
                    echo "<li><a><span>Weitere...</span></a><ul>";
                    
                    if(in_array('Device', $deviceTypeType)){
                        $tempDevicesId = array_search('Device', $deviceTypeType);
                        $tempDevicesLink = $tempDevicesId + 1;
                        unset($deviceTypeType[$tempDevicesId]);
                    }
                    for($i=0;$i<$lenght;$i++){
                        if(isset($deviceTypeType[$i])&&$i!=$tempDevicesId){
                            echo "<li><a href=\"devices.php?d=$deviceTypeId[$i]\"><span>".sanitizeOutputString($deviceTypeType[$i])."</span></a></li>";
                        }
                    }
                    
                    echo "<li><a href=\"devices.php?d=$tempDevicesLink\"><span>Sonstige</span></a></li>";
                    echo "</ul></li>";
                ?>
            </ul>
        </li>
        <li><a href='#'><span>R&auml;ume</span></a>
            <ul>
                <?php
                    $roomlevel=new roomAndLevel($connection);
                    $level=$roomlevel->getAllLevel();
                    for ($i=0;$i<count($level);$i++){
                        $tempLevelName=$level[$i]['name'];
                        $tempLevelId=$level[$i]['ID'];
                        echo "<li><a href=\"devices.php?level=$tempLevelId\">".sanitizeOutputString($tempLevelName)."</a><ul>";
                        $rooms=$roomlevel->getAllRoomsPerLevel($tempLevelId);
                        for ($j=0;$j<count($rooms);$j++){
                            $tempRoomId=$rooms[$j]['ID'];
                            $tempRoom=$rooms[$j]['name'];
                            $tempRoomNumber=$rooms[$j]['number'];
                            echo"<li><a href=\"devices.php?room=$tempRoomId\">$tempRoomNumber" . ' ' . "$tempRoom</a></li>";
                        }
                        echo "</ul></li>";
                    }
                ?>
            </ul>
        </li>
        <li><a href='#'><span>Meldungen</span></a>
            <ul>
                <li><a href="index.php">Ger&auml;te Meldungen</a></li>
                <li><a href="flag.php">Service Meldungen</a></li>
            </ul>
        </li>
        <li><a href='#'><span>Verwaltung</span></a>
            <ul>
                <li><a href="upload.php">Ger&auml;te hinzuf&uuml;gen</a></li>
                <li><a href="infrastructure.php">Patchpanel</a></li>
                <li><a href="supplier.php">Verk&auml;ufer</a></li>
                <li><a href="rooms.php">R&auml;ume und Stockwerke</a></li>
            </ul>
        </li>
        <li><a href='#'><span>Einstellungen</span></a>
        <ul>
                <li><a href="configSwitch.php">Switch Konfiguration</a></li>
                <li><a href="config.php">Service Konfiguration</a></li>
                <li><a href="custom.php">Eigene Abfragen</a></li>
                <li><a href="controlService.php">Service Steuerung</a></li>
            <li>
               <a href="user.php">Benutzer</a>
               <ul>
                   <li><a href="user.php">Benutzer Konto</a></li>
                   <?php if(isset($isAdmin) && $isAdmin){ echo '<li><a href="users.php">Benutzer Liste</a></li>';} ?>
               </ul>
            </li>           
        </ul>
        </li>
        <li><a href="logout.php">Abmelden</a></li>
        <li><a href='about.php'><span>About</span></a></li>
    </ul>
</div>
 <?php
    $connection->disconnectDB();
 ?>